package com.burgeon.backend.SHOP.controller;

import com.burgeon.backend.SHOP.entity.Goods;
import com.burgeon.backend.SHOP.service.ConsultantService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("shop/consultant")
public class ConsultantContorller extends BaseController {

    @Autowired
    private ConsultantService consultantService;

    /**
     * @author: 伯俊软件
     * @description: 公众号商品展示
     * @date: 2021/6/25 14:20
     * @param session
     * @return com.burgeon.backend.stsutil.ResponseResult<java.util.List<com.burgeon.backend.SHOP.entity.Goods>>
     */
    @RequestMapping("goodsShow")
    public ResponseResult<List<Goods>> goodsShow(HttpSession session){
        String token = session.getAttribute("token").toString();
        List<Goods> data = consultantService.goodsShow(token);
        return new ResponseResult<List<Goods>>(SUCCESS,data);
    }

    /**
     * @author: 伯俊软件
     * @description: 专属顾问
     * @date: 2021/6/25 14:57
     * @param session
     * @param name
     * @return com.burgeon.backend.stsutil.ResponseResult<java.util.HashMap>
     */
    @RequestMapping("showConsultant")
    public ResponseResult<HashMap> showConsultant(HttpSession session, String name) throws Exception {
        if(null == session.getAttribute("uid")){
            return new ResponseResult<>(NOTLOG);
        }

        String phone = session.getAttribute("phone").toString();
        String token = session.getAttribute("token").toString();
        HashMap data = consultantService.showConsultant(phone,token,name);
        return new ResponseResult<HashMap>(SUCCESS,data);

    }

    /**
     * @author: 伯俊软件
     * @description: 获取公众号二维码等信息
     * @date: 2021/7/8 17:36
     * @param token
     * @return com.burgeon.backend.stsutil.ResponseResult<java.util.HashMap>
     */
    @RequestMapping("showQrCode")
    public ResponseResult<HashMap> showQrCode(String token){
        HashMap data = consultantService.showQrCode(token);
        return new ResponseResult<HashMap>(SUCCESS,data);
    }

}
